X-Git-Url: https://git.r.bdr.sh/rbdr/captura/blobdiff_plain/5802c153cae64142d84e3cd5f762939501ee7e53..505c1e620497828ffb914e05dd76d9ab124f144a:/Captura/Core%20Extensions/CVImageBuffer%20cgImage.swift/rbdr/captura/blobdiff_plain/5802c153cae64142d84e3cd5f762939501ee7e53..505c1e620497828ffb914e05dd76d9ab124f144a:/Captura/Core%20Extensions/CVImageBuffer+cgImage.swift diff --git a/Captura/Core Extensions/CVImageBuffer+cgImage.swift b/Captura/Core Extensions/CVImageBuffer+cgImage.swift index eb62e7a..ba98855 100644 --- a/Captura/Core Extensions/CVImageBuffer+cgImage.swift +++ b/Captura/Core Extensions/CVImageBuffer+cgImage.swift @@ -18,19 +18,20 @@ import Foundation import ReplayKit extension CVImageBuffer { - + private static let contextQueue = DispatchQueue(label: "com.example.contextQueue") static let sharedContext: CIContext = { - return CIContext() + return CIContext() }() - + var cgImage: CGImage? { var result: CGImage? CVImageBuffer.contextQueue.sync { let ciImage = CIImage(cvImageBuffer: self) let width = CVPixelBufferGetWidth(self) let height = CVPixelBufferGetHeight(self) - result = CVImageBuffer.sharedContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: width, height: height)) + result = CVImageBuffer.sharedContext.createCGImage( + ciImage, from: CGRect(x: 0, y: 0, width: width, height: height)) } return result }